// 获取url参数
export function getUrlParam(name) {
  let url = decodeURI(window.location.search || window.location.hash)
  let strs
  let params = {}
  if (url.indexOf("?") != -1){
    // hash模式进此判断
    if(window.location.hash) {
      strs = url.split("?")[1].toString().split("&")
    // history模式
    }else{
      strs = url.substr(1).split("&")
    }
    // 循环遍历并添加到对象中
    for (let i = 0; i < strs.length; i++) {
      params[strs[i].split("=")[0]] = strs[i].split("=")[1]
    }
  }
  // 判断objectParams对象的长度，大于1则有值
  if(params[name]){
    return params[name]
  }else {
    return null;
  }
}